using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class FaMap : EntityTypeConfiguration<Fa>
    {
        public FaMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.ITEM)
                .HasMaxLength(20);

            this.Property(t => t.DESCR)
                .HasMaxLength(35);

            this.Property(t => t.METHOD)
                .IsRequired()
                .HasMaxLength(1);

            this.Property(t => t.DEPRACCT)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.DEPREXP)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.TABLE)
                .HasMaxLength(15);

            this.Property(t => t.VERTEX_ID)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.SUPNAME)
                .HasMaxLength(6);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.ImageName)
                .HasMaxLength(40);

            this.Property(t => t.Category)
                .HasMaxLength(20);

            this.Property(t => t.INVNO)
                .HasMaxLength(7);

            this.Property(t => t.iprcptsITEM)
                .HasMaxLength(10);

            this.Property(t => t.user_invno)
                .HasMaxLength(8);

            this.Property(t => t.Manufacturer)
                .HasMaxLength(50);

            this.Property(t => t.Model)
                .HasMaxLength(50);

            this.Property(t => t.SerialNO)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Fa");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.DESCR).HasColumnName("DESCR");
            this.Property(t => t.LIFE).HasColumnName("LIFE");
            this.Property(t => t.METHOD).HasColumnName("METHOD");
            this.Property(t => t.ACQDATE).HasColumnName("ACQDATE");
            this.Property(t => t.RETDATE).HasColumnName("RETDATE");
            this.Property(t => t.COST).HasColumnName("COST");
            this.Property(t => t.BASIS).HasColumnName("BASIS");
            this.Property(t => t.SALVAGE).HasColumnName("SALVAGE");
            this.Property(t => t.ACUMDEPR).HasColumnName("ACUMDEPR");
            this.Property(t => t.DEPRACCT).HasColumnName("DEPRACCT");
            this.Property(t => t.DEPREXP).HasColumnName("DEPREXP");
            this.Property(t => t.TABLE).HasColumnName("TABLE");
            this.Property(t => t.DEPRAMOUNT).HasColumnName("DEPRAMOUNT");
            this.Property(t => t.VERTEX_ID).HasColumnName("VERTEX_ID");
            this.Property(t => t.SUPNAME).HasColumnName("SUPNAME");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.cstctrID).HasColumnName("cstctrID");
            this.Property(t => t.ImageName).HasColumnName("ImageName");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.INVNO).HasColumnName("INVNO");
            this.Property(t => t.IpReceiptLine).HasColumnName("IpReceiptLine");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.iprcptsITEM).HasColumnName("iprcptsITEM");
            this.Property(t => t.invlink).HasColumnName("invlink");
            this.Property(t => t.BarcodePrinted).HasColumnName("BarcodePrinted");
            this.Property(t => t.currency).HasColumnName("currency");
            this.Property(t => t.user_invno).HasColumnName("user_invno");
            this.Property(t => t.Manufacturer).HasColumnName("Manufacturer");
            this.Property(t => t.Model).HasColumnName("Model");
            this.Property(t => t.SerialNO).HasColumnName("SerialNO");

            // Relationships
            this.HasRequired(t => t.Acct)
                .WithMany(t => t.Fas)
                .HasForeignKey(d => d.DEPRACCT);
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.Fas1)
                .HasForeignKey(d => d.DEPREXP);

        }
    }
}
